home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12877 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: help with strcmp
  5. Date: 2 Apr 1996 21:00:51 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4js4i3$17i@sparcserver.lrz-muenchen.de>
  9. References: <4jpiek$lp6@blaze.cs.jhu.edu> <316196CB.1125@diagram.fr> <4jr75p$onk@sparcserver.lrz-muenchen.de> <828453979snz@genesis.demon.co.uk>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. Lawrence Kirby <fred@genesis.demon.co.uk> writes:
  13.  
  14. >In article <4jr75p$onk@sparcserver.lrz-muenchen.de>
  15. >           watzka@stat.uni-muenchen.de "Kurt Watzka" writes:
  16.  
  17. >>strcmp() and strncmp() are designed to handle C strings, so they know how 
  18. >>to treat '\0' in a string. Otherwise
  19. >>
  20. >>   int STRCMP(const char *s1, const char *s2)
  21. >>   {
  22. >>      size_t sz1 = strlen(s1), sz2 = strlen(s2);
  23. >>      return strncpm(s1, s2, sz1 < sz2 ? sz1 : sz2);
  24. >>   }
  25.  
  26. >Do you have suppressed yearnings for obsolete OSs? ;-)
  27.  
  28. Yes, esp. in the afternoon when it is too late for coffee and to
  29. early for tea.
  30.  
  31. >>would be a common replacement for the then useless strcmp() function.
  32.  
  33. >Not quite, it would compare "A" and "AB" as equal.
  34.  
  35. That is exactly my point. If strcmp() would not knowe how to deal
  36. with a '\0' in a string, comparing strings of different lenght
  37. would be difficult, no matter how large the buffers that hold the
  38. two strings are.
  39.  
  40. Kurt
  41. --
  42. | Kurt Watzka                             Phone : +49-89-2180-6254
  43. | watzka@stat.uni-muenchen.de
  44.